package org.hxzon.demo.scala.matchdemo

abstract case class Trade()
case class Sell(stockSymbol: String, quantity: Int) extends Trade
case class Buy(stockSymbol: String, quantity: Int) extends Trade
case class Hedge(stockSymbol: String, quantity: Int) extends Trade

object CaseMatch {
  def process(request: Trade) {
    request match {
      case Sell(stock, 1000) => printf("Selling 1000-units of %s\n", stock)
      case Sell(stock, quantity) => printf("Selling %d units of %s\n", quantity, stock)
      case Buy(stock, quantity) if (quantity > 2000) => printf("Buying %d (large) units of %s\n", quantity, stock)
      case Buy(stock, quantity) => printf("Buying %d units of %s\n", quantity, stock)
    }
  }
  def main(args: Array[String]): Unit = {
    process(Sell("GOOG", 5000)) //Selling 5000 units of GOOG
    process(Buy("GOOG", 700)) //Buying 700 units of GOOG
    process(Sell("GOOG", 1000)) //Selling 1000-units of GOOG
    process(Buy("GOOG", 3000)) //Buying 3000 (large) units of GOOG
  }
}
